package com.itheima.model.behavior.pojos;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.io.Serializable;
import java.time.LocalDate;
import java.util.Date;

/**
 * 阅读统计实体类（按天聚合）(MongoDB)
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Document(collection = "reading_statistics")
@CompoundIndex(name = "user_date_idx", def = "{'user_id': 1, 'stat_date': 1}", unique = true)
public class ReadingStatistics implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    private String id;

    @Field("user_id")
    @Indexed
    private Integer userId;

    @Field("stat_date")
    @Indexed
    private LocalDate statDate;

    @Field("reading_time")
    private Integer readingTime;

    @Field("books_read")
    private Integer booksRead;

    @Field("notes_count")
    private Integer notesCount;

    @Field("reviews_count")
    private Integer reviewsCount;

    @Field("page_views")
    private Integer pageViews;

    @Field("create_time")
    private Date createTime;
}
